{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.4.1\n",
      "单号:  DH20140923001\n",
      "时间:2014-09-23 08:56:14\n",
      ".........................................\n",
      "名称           数量     单价     金额\n",
      "金士顿U盘8G      1      40.00    40.00 \n",
      "胜创16GTF卡      1      50.00    50.00\n",
      "读卡器           1      8.00     8.00\n",
      ".........................................\n",
      "总数： 4             总数:103.00\n",
      "折后总额:103.00\n",
      "实收:103.00        找零:0.00\n",
      "收银：管理员\n"
     ]
    }
   ],
   "source": [
    "print('2.4.1')\n",
    "print(\"单号:  DH20140923001\")\n",
    "print(\"时间:2014-09-23 08:56:14\")\n",
    "print(\".........................................\")\n",
    "print(\"名称           数量     单价     金额\")\n",
    "print(\"金士顿U盘8G      1      40.00    40.00 \")\n",
    "print(\"胜创16GTF卡      1      50.00    50.00\")\n",
    "print(\"读卡器           1      8.00     8.00\")\n",
    "print(\".........................................\")\n",
    "print(\"总数： 4             总数:103.00\")\n",
    "print(\"折后总额:103.00\")\n",
    "print(\"实收:103.00        找零:0.00\")\n",
    "print(\"收银：管理员\")\n",
    "  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.4.2\n",
      "            植树证书                   \n",
      "             谢谢你                    \n",
      "你于2019年11月3日申请种植的梭梭树,\n",
      "已被中国扶贫基金会认领，将种植到武威\n",
      "地区。\n",
      "          树苗编号          \n",
      "      NO. HFK20308960305           \n"
     ]
    }
   ],
   "source": [
    "print('2.4.2')\n",
    "print(\"            植树证书                   \")\n",
    "print(\"             谢谢你                    \")\n",
    "print(\"你于2019年11月3日申请种植的梭梭树,\\n\"\n",
    "       \"已被中国扶贫基金会认领，将种植到武威\\n\"\n",
    "       \"地区。\")\n",
    "print(\"          树苗编号          \")\n",
    "print(\"      NO. HFK20308960305           \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.7.1\n",
      "55.0 摄氏度对应的卡尔文为: 328.15\n"
     ]
    }
   ],
   "source": [
    "print('2.7.1')\n",
    "celsius=float(input(\"请输入摄氏温度:\"))\n",
    "kelvin=celsius+273.15\n",
    "print(celsius,\"摄氏度对应的卡尔文为:\",kelvin)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.7.2\n",
      "您的BMT的值为: 150.0\n"
     ]
    }
   ],
   "source": [
    "print('2.7.2')\n",
    "height=float(input('请输入您的身高(m):'))\n",
    "weight=float(input('请输入您的体重(kg):'))\n",
    "BMT=weight/height*height\n",
    "print('您的BMT的值为:',BMT)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.2.1\n",
      "-3.0\n"
     ]
    }
   ],
   "source": [
    "print('3.2.1')\n",
    "first=float(input(\"请输入第一个数：\"))\n",
    "second=float(input(\"请输入第二个数：\"))\n",
    "operator=input(\"请选择运算符：+ - * \\:\")\n",
    "if operator=='+':\n",
    "    print(first+second)\n",
    "elif operator=='-':\n",
    "    print(first-second)\n",
    "elif operator=='*':\n",
    "    print(first*second)\n",
    "elif operator=='/':\n",
    "    if second==0:\n",
    "        print(\"除数不能为零\")\n",
    "    else:\n",
    "        print(first/second)\n",
    "            \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.2.2\n",
      "很遗憾，你猜大了\n",
      "很遗憾，你猜大了\n",
      "很遗憾，你猜小了\n",
      "很遗憾，你猜小了\n",
      "恭喜你用了5次猜对了\n"
     ]
    }
   ],
   "source": [
    "print('3.2.2')\n",
    "guess_num=input(\"请设定猜数的数值：\\n\")\n",
    "for frequency in range(1,6):\n",
    "    number=input(\"请输入第\"+str(frequency)+\"次猜测的数字\")\n",
    "    if number.isdigit() is False:\n",
    "        print(\"请输入一个正确的数字\")\n",
    "    elif int(number)<0 or int(number)>100:\n",
    "        print(\"请输入一个1-100之间的数字\")\n",
    "    elif int(guess_num)==int(number):\n",
    "        print(\"恭喜你用了%d次猜对了\" % frequency)\n",
    "        break\n",
    "    elif int(guess_num)<int(number):\n",
    "        print(\"很遗憾，你猜大了\")\n",
    "    else:\n",
    "        print(\"很遗憾，你猜小了\")\n",
    "    if frequency==5:\n",
    "        print(\"很遗憾，%d次机会已经有用尽了，游戏结束了，答案为%d\" % frequency,int(guess_num))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.4.1\n",
      "1、2、3、4、5、6、*、8、9、10、11、12、13、*、15、16、*、18、19、20、*、22、23、24、25、26、*、*、29、30、31、32、33、34、*、36、*、38、39、40、41、*、43、44、45、46、*、48、*、50、51、52、53、54、55、*、*、58、59、60、61、62、*、64、65、66、*、68、69、*、*、*、*、*、*、*、*、*、*、80、81、82、83、*、85、86、*、88、89、90、*、92、93、94、95、96、*、*、99、100、"
     ]
    }
   ],
   "source": [
    "print('3.4.1')\n",
    "for i in range(1,101):\n",
    "    if \"7\"in str(i) or int(i)%7==0:\n",
    "        print('*',end=\"、\")\n",
    "    elif \"7\" not in str(i) or int(i)%7==0:\n",
    "        print(i,end=\"、\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.4.2\n",
      " ┏  ┯  ┯  ┯  ┯  ┯  ┯  ┯  ┯  ┯  ┯  ┯  ┯  ┯  ┓ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┠  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┼  ┨ \n",
      " ┗  ┷  ┷  ┷  ┷  ┷  ┷  ┷  ┷  ┷  ┷  ┷  ┷  ┷  ┛ \n"
     ]
    }
   ],
   "source": [
    "print('3.4.2')\n",
    "size=int(input(\"请输入棋盘的大小：\"))\n",
    "for i in range(size):\n",
    "    for j in range(size):\n",
    "        if  i == 0 and j == 0:    \n",
    "         print(\" ┏ \",end='')            \n",
    "        elif i == 0 and j == size-1:    \n",
    "             print(\" ┓ \",end='')\n",
    "        elif i == size-1 and j == 0:    \n",
    "             print(\" ┗ \",end='')\n",
    "        elif i == size-1 and j == size-1:    \n",
    "             print(\" ┛ \",end='')\n",
    "        elif j == 0:    \n",
    "             print(\" ┠ \",end='')\n",
    "        elif i == size-1:    \n",
    "             print(\" ┷ \",end='')\n",
    "        elif j == size-1:    \n",
    "             print(\" ┨ \",end='')       \n",
    "        elif i == 0:                    \n",
    "             print(\" ┯ \",end='')\n",
    "        else:\n",
    "             print(\" ┼ \",end='')\n",
    "    print('')\n",
    "\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.6\n"
     ]
    }
   ],
   "source": [
    "print('3.6')\n",
    "while True:\n",
    "    loan_type=input(\"请选择贷款类型：1.商业贷款 2。公积金贷款 3.组合贷款\\n\")\n",
    "    if  loan_type != '3':\n",
    "        loan_amount = float(input(\"请输入贷款金额（万)\\n\"))\n",
    "        term=int(input(\"请选择期限（年）：5、10、15、20、25\\n\"))\n",
    "        if term in [5,10,15,20,25]:\n",
    "            if term==5:\n",
    "                mon_rate = (4.75/100)/12\n",
    "                mon_pay = loan_amount*10000*(mon_rate*((1+mon_rate)**(term*12)))/((1+mon_rate)**(term*12)-1)\n",
    "                all_pay = mon_pay * term * 12\n",
    "                interest=all_pay-loan_amount+10000\n",
    "                print(\"每月月供参考（元):{:.2f}元\".format(mon_pay))\n",
    "                print(\"支付利息（元）：{:.2f}\".format(interest))\n",
    "                print(\"还贷总额（元）：{:.2f}\".format(all_pay))\n",
    "            else:   \n",
    "                    if  loan_type=='1':\n",
    "                        mon_rate=(4.90/100)/12\n",
    "                        mon_pay = loan_amount*10000*(mon_rate*((1+mon_rate)**(term*12)))/((1+mon_rate)**(term*12)-1)\n",
    "                        all_pay=mon_pay*term*12\n",
    "                        interst=all_pay-loan_amount*10000\n",
    "                        print(\"每月月供参考（元):{:.2f}元\".format(mon_pay))\n",
    "                        print(\"支付利息（元）：{:.2f}\".format(interest))\n",
    "                        print(\"还贷总额（元）：{:.2f}\".format(all_pay))\n",
    "                    elif   loan_type=='2':\n",
    "                        if term==5:\n",
    "                            mon_rate=(2.75/100)/12\n",
    "                            mon_rate=(3.25/100)/12\n",
    "                            mon_pay=loan_amount*10000*(mon_rate*((1+mon_rate)**(term*12)))/(((1+mon_rate)**(term*12))-1)\n",
    "                            all_pay=mon_pay*term*12\n",
    "                            interst=all_pay-loan_amount*10000\n",
    "                            print(\"每月月供参考（元):{:.2f}元\".format(mon_pay))\n",
    "                            print(\"支付利息（元）：{:.2f}\".format(interest))\n",
    "                            print(\"还贷总额（元）：{:.2f}\".format(all_pay))\n",
    "                        else:\n",
    "                            print('请输入合法的期限')\n",
    "                    else:\n",
    "                        business_loan=float(input(\"请输入商业贷款金额（万）:\\n\"))\n",
    "                        found_loan=float(input(\"请输入公积金贷款金额（万）:\\n\"))\n",
    "                        term=int(input(\"请选择期限（年）：5、10、15、20、25\\n\"))\n",
    "                        if term in [5,10,15,20,25]:\n",
    "                            if term==5:\n",
    "                                business_mon_rate=(4.75/100)/12\n",
    "                                found_mon_rate=(2.75/100)/12\n",
    "                            else:\n",
    "                                business_mon_rate=(4.90/100)/12\n",
    "                                found_mon_rate=(3.25/100)/12\n",
    "                            business_mon_pay=business_loan*10000*(business_mon_rate*((1+business_mon_rate)**(term*12)))/(((1+business_mon_rate)**(term*12))-1)    \n",
    "                            found_mon_pay=found_loan*10000*(found_mon_rate*((1+found_mon_rate)**(term*12)))/(((1+found_mon_rate)**(term*12))-1)   \n",
    "                            mon_all_pay=business_mon_pay+found_mon_pay\n",
    "                            all_pay=mon_all_pay*term*12\n",
    "                            interest=all_pay-(business_loan+found_loan)*10000\n",
    "                            print(\"每月月供参考（元):{:.2f}元\".format(mon_pay))\n",
    "                            print(\"支付利息（元）：{:.2f}\".format(interest))\n",
    "                            print(\"还贷总额（元）：{:.2f}\".format(all_pay))\n",
    "                        else:\n",
    "                            print('请输入合法的期限')\n",
    "                            \n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "   \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "该半径对应的圆的直径为: 8.0\n",
      "该半径对应的圆的面积为: 50.26548245743669\n"
     ]
    }
   ],
   "source": [
    "print(\"33页第一题\")\n",
    "import math\n",
    "radius=float(input(\"请输入圆的半径:\"))\n",
    "S=math.pi*radius*radius\n",
    "l=2*radius\n",
    "print(\"该半径对应的圆的直径为:\",l)\n",
    "print(\"该半径对应的圆的面积为:\",S)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "33页第二题\n",
      "要送的次数为 7.0\n"
     ]
    }
   ],
   "source": [
    "print(\"33页第二题\")\n",
    "c=(29.5-4*3)/2.5\n",
    "print(\"要送的次数为\",c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "44页第一题\n",
      "0\n",
      "2\n",
      "4\n",
      "6\n",
      "8\n",
      "10\n",
      "12\n",
      "14\n",
      "16\n",
      "18\n",
      "20\n",
      "22\n",
      "24\n",
      "26\n",
      "28\n",
      "30\n",
      "32\n",
      "34\n",
      "36\n",
      "38\n",
      "40\n",
      "42\n",
      "44\n",
      "46\n",
      "48\n",
      "50\n",
      "52\n",
      "54\n",
      "56\n",
      "58\n",
      "60\n",
      "62\n",
      "64\n",
      "66\n",
      "68\n",
      "70\n",
      "72\n",
      "74\n",
      "76\n",
      "78\n",
      "80\n",
      "82\n",
      "84\n",
      "86\n",
      "88\n",
      "90\n",
      "92\n",
      "94\n",
      "96\n",
      "98\n",
      "100\n"
     ]
    }
   ],
   "source": [
    "print(\"44页第一题\")\n",
    "num = 0\n",
    "while num <= 100:\n",
    "  if num % 2 == 0:\n",
    "     print(num)\n",
    "     num += 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "44页第二题\n",
      "输入的数是正数\n"
     ]
    }
   ],
   "source": [
    "print(\"44页第二题\")\n",
    "num = int(input(\"请输入一个数:\"))\n",
    "if num > 0:\n",
    "   print(\"输入的数是正数\")\n",
    "elif num < 0:\n",
    "   print(\"输入的数是负数\")\n",
    "else:\n",
    "   print(\"输入的数是0\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "44页第三题\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n",
      "11\n",
      "13\n",
      "15\n",
      "17\n",
      "19\n",
      "21\n",
      "23\n",
      "25\n",
      "27\n",
      "29\n",
      "31\n",
      "33\n",
      "35\n",
      "37\n",
      "39\n",
      "41\n",
      "43\n",
      "45\n",
      "47\n",
      "49\n",
      "51\n",
      "53\n",
      "55\n",
      "57\n",
      "59\n",
      "61\n",
      "63\n",
      "65\n",
      "67\n",
      "69\n",
      "71\n",
      "73\n",
      "75\n",
      "77\n",
      "79\n",
      "81\n",
      "83\n",
      "85\n",
      "87\n",
      "89\n",
      "91\n",
      "93\n",
      "95\n",
      "97\n",
      "99\n"
     ]
    }
   ],
   "source": [
    "print(\"44页第三题\")\n",
    "i = 2\n",
    "for i in range(2,100):\n",
    "  if i % 2 != 0:\n",
    "    print(i)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
